package soul.mq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.UnsupportedEncodingException;
//@Component
public class MQMessageListener implements MessageListener {

    private static final Logger LOGGER = LoggerFactory.getLogger(MQMessageListener.class);

    public void onMessage(Message message) {
        try {
            String s = new String(message.getBody(), "UTF-8");
            MessageProperties messageProperties = message.getMessageProperties();
            simpleProcess(s);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    @Transactional
    private void simpleProcess(String msg) {

    }
}
